//
//  AppointmentController.m
//  仿真开发
//
//  Created by Cloud on 2017/3/23.
//  Copyright © 2017年 B.HOPE. All rights reserved.
//

#import "AppointmentController.h"
#import <Masonry.h>
#import "UILabel+HMAddition.h"
#import "UIColor+HMAddition.h"
#import "RadioButton.h"
#import "AppointDoctorView.h"
#import "HMReputationDoctor.h"
#import "HMTumourTableViewController.h"
#import "HMComplicationTableViewController.h"
#import "HMDidTreatTableViewController.h"
#import "HMTool.h"
#import <YYModel.h>
#import "HMMatchingDoc.h"
#import "AppointModel.h"

@interface AppointmentController () <HMTumourTableViewControllerDelegate,HMComplicationTableViewControllerDelegate,HMDidTreatTableViewControllerDelegate>

@property (nonatomic, strong)UIStoryboard *story;

/**
 记录确诊按钮
 */
@property(weak, nonatomic)RadioButton *radioBtn1;

/**
 记录疑似按钮

 */
@property(weak, nonatomic)RadioButton *radioBtn2;

/**
 记录是否有医疗史按钮1
 */
@property(weak, nonatomic)RadioButton *Tradio1;

/**
 记录是否有医疗史按钮2
 */
@property(weak, nonatomic)RadioButton *Tradio2;

/**
 记录申请按钮
 */
@property(weak, nonatomic)UIButton *appointButton;

/**
 记录医疗史view
 */
@property(weak, nonatomic)UIView *fourView;

/**
 记录曾经治疗的view
 */
@property(strong, nonatomic)UIView *missView;

/**
 记录病名
 */
@property(nonatomic, strong) NSString *illName;

/**
 记录预约label
 */
@property(nonatomic, weak) UILabel *orderLabel;

/**
 记录预约view
 */
@property(nonatomic, strong) UIView *orderView;

/**
 记录label
 */
@property(nonatomic, weak) UILabel *threeLabel;

/**
 记录匹配医生的数量
 */
@property(nonatomic, strong) NSNumber *doc_count;

/**
 记录第一行的label
 */
@property (weak,nonatomic)UILabel *oneLabel;


/**
 记录第二行的label
 */
@property (weak,nonatomic)UILabel *twoLabel;

/**
 记录第二行btn
 */
@property (weak,nonatomic)UIButton *twoBtn;

/**
 记录模型
 */
@property (strong,nonatomic) AppointModel *model;

/**
 记录预约按钮
 */
@property (weak,nonatomic) UIButton *orderBtn;


@property (nonatomic,assign) BOOL selected;

@end

@implementation AppointmentController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor hm_colorWithRed:239 green:239 blue:243];
    [self setupUI];
    
    
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [self loadData];
    
    
}

#pragma mark - 选项UI
- (void)setupUI
{
#pragma mark - 设置疾病类型
    UILabel *label = [UILabel hm_labelWithText:[NSString stringWithFormat:@"  疾病类型:%@",self.title] fontSize:17 color:[UIColor grayColor]];
    [self.view addSubview:label];
    //设置约束
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_topLayoutGuideBottom).mas_offset(24);
        make.left.equalTo(self.view).mas_offset(16);
        make.trailing.equalTo(self.view).mas_equalTo(-16);
        make.height.mas_equalTo(30);
    }];
    
    self.type = label;
    
#pragma mark - 设置疾病情况选择
    UIView *oneView = [[UIView alloc] init];
    oneView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:oneView];
    
    //设置约束
    [oneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(label.mas_bottom).mas_offset(16);
        make.left.right.equalTo(label);
        make.height.mas_equalTo(40);
    }];
    
    //设置圆角
    oneView.layer.cornerRadius = 10;
    
    //添加label
    UILabel *oneLabel = [[UILabel alloc] init];
    oneLabel.text = @"请选择疾病类型:";
    oneLabel.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [oneView addSubview:oneLabel];
    [oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(oneView).mas_offset(5);
        make.bottom.equalTo(oneView).mas_offset(-5);
    }];
    
    _oneLabel = oneLabel;
    
    //添加右边箭头
    UIButton *rightBtn = [[UIButton alloc] init];
    [rightBtn setImage:[UIImage imageNamed:@"position-right"] forState:UIControlStateNormal];
    [rightBtn setImage:[UIImage imageNamed:@"product_button_input_jianjiao.png"] forState:UIControlStateHighlighted];
    [oneView addSubview:rightBtn];
    [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(oneView).mas_offset(5);
        make.bottom.equalTo(oneView).mas_offset(-5);
        make.right.equalTo(oneView).mas_offset(-20);
    }];
    
//添加点击事件
    UITapGestureRecognizer *oneType = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchOne:)];
    [oneView addGestureRecognizer:oneType];
    [rightBtn addTarget:self action:@selector(touchOne:) forControlEvents:UIControlEventTouchUpInside];
    
#pragma mark - 设置并发症选择
    
    UIView *twoView = [[UIView alloc] init];
    twoView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:twoView];
    
    //设置约束
    [twoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(oneView.mas_bottom).mas_offset(16);
        make.left.right.equalTo(oneView);
        make.height.mas_equalTo(40);
    }];
    twoView.layer.cornerRadius = 10;
    
    //设置label
    UILabel *twoLabel = [[UILabel alloc] init];
    twoLabel.text = @"请选择并发症(多选):";
    [twoView addSubview:twoLabel];
    twoLabel.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [twoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(twoView).mas_offset(5);
        make.bottom.equalTo(twoView).mas_offset(-5);
        make.width.offset(300);
    }];
    
    _twoLabel = twoLabel;
    //添加右边箭头
    UIButton *twoBtn = [[UIButton alloc] init];
    [twoBtn setImage:[UIImage imageNamed:@"position-right"] forState:UIControlStateNormal];
    [twoBtn setImage:[UIImage imageNamed:@"product_button_input_jianjiao.png"] forState:UIControlStateHighlighted];
    [twoView addSubview:twoBtn];
    [twoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(twoView).mas_offset(5);
        make.bottom.equalTo(twoView).mas_offset(-5);
        make.right.equalTo(twoView).mas_offset(-20);
    }];
    
    _twoBtn = twoBtn;
    
//添加点击事件
    UITapGestureRecognizer *twoType = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchTwo:)];
    [twoView addGestureRecognizer:twoType];
    [twoBtn addTarget:self action:@selector(touchTwo:) forControlEvents:UIControlEventTouchUpInside];
    
#pragma mark - 设置是否确诊
    
    UIView *threeView = [[UIView alloc] init];
    threeView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:threeView];
    [threeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(twoView.mas_bottom).mas_offset(16);
        make.left.right.equalTo(twoView);
        make.height.mas_offset(40);
    }];
    threeView.layer.cornerRadius = 10;
    
    //设置label
    UILabel *threeLabel = [[UILabel alloc] init];
    threeLabel.text = @"是否已确诊:";
    threeLabel.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [threeView addSubview:threeLabel];
    [threeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(threeView).mas_offset(5);
        make.bottom.equalTo(threeView).mas_offset(-5);
    }];
    
    //添加单选按钮
    RadioButton *radio1 = [[RadioButton alloc] init];
    [radio1 setImage:[UIImage imageNamed:@"select_default"] forState:UIControlStateNormal];
    [radio1 setImage:[UIImage imageNamed:@"select_click"] forState:UIControlStateSelected];
    [threeView addSubview:radio1];
    [radio1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(15);
        make.centerY.equalTo(threeView);
        make.right.equalTo(threeView).mas_offset(-140);
    }];
    
    [radio1 addTarget:self action:@selector(clickSure) forControlEvents:UIControlEventTouchUpInside];
    
    //添加单选按钮label
    UILabel *radio1Label = [[UILabel alloc] init];
    radio1Label.text = @"确诊";
    radio1Label.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [threeView addSubview:radio1Label];
    [radio1Label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(radio1);
        make.left.equalTo(radio1.mas_right).mas_offset(5);
    }];
    
    //添加单选按钮
    RadioButton *radio2 = [[RadioButton alloc] init];
    [radio2 setImage:[UIImage imageNamed:@"select_default"] forState:UIControlStateNormal];
    [radio2 setImage:[UIImage imageNamed:@"select_click"] forState:UIControlStateSelected];
    [threeView addSubview:radio2];
    [radio2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(15);
        make.centerY.equalTo(threeView);
        make.right.equalTo(radio1Label.mas_right).mas_offset(30);
    }];
    
    [radio2 addTarget:self action:@selector(clickSuspect) forControlEvents:UIControlEventTouchUpInside];
    
    //添加单选按钮label
    UILabel *radio2Label = [[UILabel alloc] init];
    radio2Label.text = @"疑似";
    radio2Label.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [threeView addSubview:radio2Label];
    [radio2Label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(radio2);
        make.left.equalTo(radio2.mas_right).mas_offset(5);
    }];
    
    //设置一组单选按钮
//    radio1.groupButtons = @[radio1,radio2];
//    self.radioBtn1 = radio1;
    
    _radioBtn1 = radio1;
    _radioBtn2 = radio2;
    
#pragma mark - 设置是否有医疗史
    UIView *fourView = [[UIView alloc] init];
    fourView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:fourView];
    [fourView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(threeView.mas_bottom).mas_offset(16);
        make.left.right.equalTo(threeView);
        make.height.mas_offset(40);
    }];
    fourView.layer.cornerRadius = 10;
    _fourView = fourView;
    
    //设置label
    UILabel *fourLabel = [[UILabel alloc] init];
    fourLabel.text = @"是否有医疗史:";
    fourLabel.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [fourView addSubview:fourLabel];
    [fourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(fourView).mas_offset(5);
        make.bottom.equalTo(fourView).mas_offset(-5);
    }];
    
    //添加单选按钮
    RadioButton *Tradio1 = [[RadioButton alloc] init];
    [Tradio1 setImage:[UIImage imageNamed:@"select_default"] forState:UIControlStateNormal];
    [Tradio1 setImage:[UIImage imageNamed:@"select_click"] forState:UIControlStateSelected];
    [fourView addSubview:Tradio1];
    [Tradio1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(15);
        make.centerY.equalTo(fourView);
        make.right.equalTo(fourView).mas_offset(-140);
    }];
    
    // 添加按钮点击事件
    
    [Tradio1 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    
    //添加单选按钮label
    UILabel *Tradio1Label = [[UILabel alloc] init];
    Tradio1Label.text = @"存在";
    Tradio1Label.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [fourView addSubview:Tradio1Label];
    [Tradio1Label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(Tradio1);
        make.left.equalTo(Tradio1.mas_right).mas_offset(5);
    }];
    
    //添加单选按钮
    RadioButton *Tradio2 = [[RadioButton alloc] init];
    [Tradio2 setImage:[UIImage imageNamed:@"select_default"] forState:UIControlStateNormal];
    [Tradio2 setImage:[UIImage imageNamed:@"select_click"] forState:UIControlStateSelected];
    [fourView addSubview:Tradio2];
    [Tradio2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(15);
        make.centerY.equalTo(fourView);
        make.right.equalTo(radio1Label.mas_right).mas_offset(30);
    }];
    
     [Tradio2 addTarget:self action:@selector(clickRemove:) forControlEvents:UIControlEventTouchUpInside];
    
    
    //添加单选按钮label
    UILabel *Tradio2Label = [[UILabel alloc] init];
    Tradio2Label.text = @"没有";
    Tradio2Label.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    [fourView addSubview:Tradio2Label];
    [Tradio2Label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(Tradio2);
        make.left.equalTo(Tradio2.mas_right).mas_offset(5);
    }];
    
   
    
    //设置一组单选按钮
    
//    Tradio1.groupButtons = @[Tradio1,Tradio2];
    
    _Tradio1 = Tradio1;
    _Tradio2 = Tradio2;

    
//添加点击事件
    
#pragma mark - 设置申请预约
    
    UIButton *btn = [[UIButton alloc] init];
    btn.backgroundColor = [UIColor grayColor];
    [self.view addSubview:btn];
    
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).mas_offset(-15);
        make.centerX.equalTo(self.view);
        make.width.mas_offset(300);
        make.height.mas_offset(40);
    }];
    btn.layer.cornerRadius = 10;
    self.appointButton = btn;
    //设置label
    UILabel *lab = [[UILabel alloc] init];
    lab.text = @"申请预约";
    lab.textColor = [UIColor whiteColor];
    [btn addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.centerY.equalTo(btn);
        
    }];
    _orderBtn = btn;
    _orderLabel = lab;
    
    
}




- (void) touchAppoin:(UIButton *)senter
{
    _story = [UIStoryboard storyboardWithName:@"AppointDoctorView" bundle:nil];
    
//    AppointDoctorView *vc = [_story instantiateViewControllerWithIdentifier:@"123"];
    HMReputationDoctor *doctor = [[HMReputationDoctor alloc] init];
    [self.navigationController pushViewController:doctor animated:YES];
    self.navigationItem.backBarButtonItem.title = @"返回申请";
    
    /*Main 是storyboar的资源名
     _storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
     
     //实例化一个所要push的控制器
     
     PerfectInformationViewController *informationVC = [_storyBoard instantiateViewControllerWithIdentifier:@"informationVC"];
     */
    
    
}

#pragma mark - 设置曾经的治疗方式
// 懒加载 曾经治疗
- (UIView *)missView {
    
    if (_missView == nil) {
        _missView = [[UIView alloc] init];
        _missView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_missView];
        
        //设置约束
        [_missView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_fourView.mas_bottom).mas_offset(16);
            make.left.right.equalTo(_fourView);
            make.height.mas_offset(40);
        }];
        
        //设置圆角
        _missView.layer.cornerRadius = 10;
        
        //添加label
        UILabel *missLabel = [[UILabel alloc] init];
        missLabel.text = @"曾经的治疗方式:";
        missLabel.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
        [_missView addSubview:missLabel];
        [missLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(_missView).mas_offset(5);
            make.bottom.equalTo(_missView).mas_offset(-5);
        }];
        
        _threeLabel = missLabel;
        
        //添加右边箭头
        UIButton *missBtn = [[UIButton alloc] init];
        [missBtn setImage:[UIImage imageNamed:@"position-right"] forState:UIControlStateNormal];
        [missBtn setImage:[UIImage imageNamed:@"product_button_input_jianjiao.png"] forState:UIControlStateHighlighted];
        [_missView addSubview:missBtn];
        [missBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_missView).mas_offset(5);
            make.bottom.equalTo(_missView).mas_offset(-5);
            make.right.equalTo(_missView).mas_offset(-20);
        }];
        
        
        UITapGestureRecognizer *threeType = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchThree:)];
        [_missView addGestureRecognizer:threeType];
        [missBtn addTarget:self action:@selector(touchThree:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _missView;
    
}

#pragma mark - 匹配医生UI
- (UIView *) orderView{
    if (_orderView == nil) {
        _orderView = [[UIView alloc] init];
        
        [self.view addSubview:_orderView];
        [_orderView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.orderLabel).offset(-35);
            make.top.equalTo(self.missView).offset(45);
            make.width.offset(self.view.bounds.size.width);
        }];
        
        //匹配label
        UILabel *firstLabel = [UILabel hm_labelWithText:@"一共为你匹配到" fontSize:18 color:[UIColor grayColor]];
        [_orderView addSubview:firstLabel];
        
        //医生数量label
        UILabel *lastLabel = [[UILabel alloc] init];
        lastLabel.text = [NSString stringWithFormat:@"%@位医生",_doc_count];
        lastLabel.font = [UIFont boldSystemFontOfSize:20.0f]; ;
        lastLabel.textColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
        
        [_orderView addSubview:lastLabel];
        
        
        //图片view
        UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"doctorCount"]];
        [_orderView addSubview:img];
        
        [img mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.appointButton.mas_top).mas_offset(-32);
            make.centerX.equalTo(self.appointButton);
        }];
        
        [lastLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(img.mas_top).mas_offset(-16);
            make.centerX.equalTo(img);
        }];
        
        [firstLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(lastLabel.mas_top).mas_offset(-16);
            make.centerX.equalTo(img);
        }];
        
        

    }
    return _orderView;
    
}

- (void)clickSure {
    if (_oneLabel.text != _illName) {
        [self setPromptBoxWithTitle:@"CKL的温情提示" andMessage:@"请选择疾病类型" andBtnTitle:@"返回"];
        _radioBtn1.selected = NO;
    } else {
        _radioBtn1.selected = YES;
        _radioBtn2.selected = NO;
    }
}

- (void)clickSuspect {
    if (_oneLabel.text != _illName) {
        [self setPromptBoxWithTitle:@"CKL的温情提示" andMessage:@"请选择疾病类型" andBtnTitle:@"返回"];
        _radioBtn2.selected = NO;
    } else {
        _radioBtn2.selected = YES;
        _radioBtn1.selected = NO;
    }
}

#pragma mark - 点击 医疗史[存在]按钮
- (void)click : (RadioButton *)radBtn{
    
    // 如果第一行数据有值
    if (_oneLabel.text == _illName){
        // 存在按钮 可选
        _Tradio1.selected = YES;
        // 没有按钮 不可选
        _Tradio2.selected = NO;
        
        // 读取 曾经的治疗View
        [self missView];
        [self orderView];
        
        // 如果点击[存在] 按钮
        if (_Tradio1.selected || _radioBtn1.selected || _radioBtn2.selected ) {
            
            // 申请预约的按钮的可以添加点击事件
            [_orderBtn addTarget:self action:@selector(touchAppoin:) forControlEvents:UIControlEventTouchUpInside];
            
            // 把申请预约的按钮更改背景颜色
            _orderBtn.backgroundColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
        }
        
    // 如果第一行没值
    } else {
        _Tradio1.selected = NO;
        
        // 设置提示框
        [self setPromptBoxWithTitle:@"CKL的温情提示" andMessage:@"请选择疾病类型" andBtnTitle:@"返回"];

    }
    
}

#pragma mark - 点击 医疗史[没有]按钮
- (void) clickRemove:(RadioButton *)radBtn{
    
    // 如果第一行 疾病类型没有值
    if (_oneLabel.text != _illName) {
        // 设置提示框
        [self setPromptBoxWithTitle:@"CKL的温情提示" andMessage:@"请选择疾病类型" andBtnTitle:@"返回"];
        // 不能选中
        _Tradio2.selected = NO;

    // 如果疾病类型有值,就把[曾经的治疗方式]的View给移除
    }else{
        
        

        // 申请预约的按钮的可以添加点击事件
        [_orderBtn addTarget:self action:@selector(touchAppoin:) forControlEvents:UIControlEventTouchUpInside];
        
        // 把申请预约的按钮更改背景颜色
        _orderBtn.backgroundColor = [UIColor hm_colorWithRed:78 green:194 blue:156];
    
        [self orderView];
        
        [_missView removeFromSuperview];
        // 给View赋值nil,就可以重新加载
        _missView = nil;
        
        _Tradio2.selected =  YES;
        _Tradio1.selected = NO;


    }

    
}


#pragma mark - 手势触碰方法
// 点击疾病类型
- (void)touchOne:(UITapGestureRecognizer *)sender{
    
    HMTumourTableViewController *tb = [[HMTumourTableViewController alloc] init];
    tb.tag = self.tag;
    [self.navigationController pushViewController:tb animated:YES];
    tb.delegate= self;
    [tb.tableView reloadData];
}

// 点击并发疾病类型
- (void)touchTwo:(UITapGestureRecognizer *)sender {
    // 判断 如果_ControllerTag  类型是胃恶性肿瘤 就创建并发疾病控制器
    if ([_ControllerTag isEqualToString:@"胃恶性肿瘤"]) {
        HMComplicationTableViewController *cctb = [[HMComplicationTableViewController alloc] init];
        cctb.tag = self.tag;
        cctb.delegate = self;
        //  不选择疾病类型 就选择不了第二个并发类型
        if (cctb.tag != 1) {
            [self.navigationController pushViewController:cctb animated:YES];
        }
        [cctb.tableView reloadData];
        
    // 判断如果是其他疾病 就显示没有并发症
    }else if (_ControllerTag) {
        NSLog(@"没有并发症");
        // 设置提示框
        [self setPromptBoxWithTitle:@"CKL的温馨提示" andMessage:@"此症状没有并发症" andBtnTitle:@"返回"];
        
    // 否则就显示选择疾病类型
    }else{
        NSLog(@"请选择疾病类型");
        // 设置提示框
        [self setPromptBoxWithTitle:@"CKL的温馨提示" andMessage:@"请选择疾病类型" andBtnTitle:@"返回"];
    }
    
}

// 点击曾经治疗方式
- (void)touchThree:(UITapGestureRecognizer *)sender {
    
    HMDidTreatTableViewController *didTreat = [[HMDidTreatTableViewController alloc] init];
    
    [self.navigationController pushViewController:didTreat animated:YES];
    
    didTreat.delegate = self;
}

#pragma mark - 3个tableView Controller的代理方法
// 实现返回文字的代理方法,让选择疾病类型 返回被点击的cell的文字
- (void)HMTumourTableViewController:(HMTumourTableViewController *)vc illName:(NSString *)illName {
    
//    _model.ci3_name = illName;
    
    _illName = illName;
    _oneLabel.text = illName;
    
    
    
}

// 实现返回疾病名的代理方法,让_ControllerTag 拿到疾病类型
- (void)HMTumourTableViewController:(HMTumourTableViewController *)vc Tag:(NSString *)tag {
    _ControllerTag = tag;
}

// 实现并发疾病代理
- (void)HMComplicationTableViewController:(HMComplicationTableViewController *)compVc andillName:(NSArray *)illName {
    
    NSMutableString *strM = [NSMutableString string];
    
    for (AppointModel *model in illName) {
        [strM appendString:  [NSString stringWithFormat:@"%@   ",model.complication_name]];
//        NSString *str = [NSString stringWithFormat:@"%@ , %@",strM,strM];
        _twoLabel.text = strM;
        
        
    }
    
    [_twoBtn removeFromSuperview];
}

// 实现曾经治疗方法
- (void)HMDidTreatTableViewController:(HMDidTreatTableViewController *)vc andStr:(NSString *)str{
    
    _threeLabel.text = str;
    
}


// 封装提示框
- (void)setPromptBoxWithTitle: (NSString *)title andMessage: (NSString *)message andBtnTitle:(NSString *)btnTitle {
    
    UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    // 设置按钮
    UIAlertAction *ac1 = [UIAlertAction actionWithTitle:btnTitle style:UIAlertActionStyleDefault handler:nil];
    
    [alertCtrl addAction:ac1];
    
    [self presentViewController:alertCtrl animated:YES completion:nil];
    
}

// 读取匹配医生接口
- (void)loadData {
    NSString *url = @"http://iosapi.itcast.cn/doctor/matchedDoctorCount.json.php";
    NSDictionary *parameters = @{@"ci1_id":@1,@"ci2_id":@3,@"ci3_id":@3,@"diagnosis_type":@0,@"is_confirmed":@1,@"user_id":@1000089, @"has_diagnosis":@2};
    
    [[HMTool sharedNetworkTool]POSTWithURLString:url parameters:parameters success:^(id responseObject) {
        
        // 解析json
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:NULL];
        
        NSDictionary *dataDic = dic[@"data"];
        
        NSNumber *doc_count = dataDic[@"doctor_count"];
        
        _doc_count = doc_count;
        
    } faile:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}

@end
